import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BuildingUnitForm, BuildingUnitQuery, BuildingUnitVO } from '@/api/system/buildingUnit/types';

/**
 * 查询房产单元管理列表
 * @param query
 * @returns {*}
 */

export const listBuildingUnit = (query?: BuildingUnitQuery): AxiosPromise<BuildingUnitVO[]> => {
  return request({
    url: '/system/buildingUnit/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询房产单元管理详细
 * @param unitId
 */
export const getBuildingUnit = (unitId: string | number): AxiosPromise<BuildingUnitVO> => {
  return request({
    url: '/system/buildingUnit/' + unitId,
    method: 'get'
  });
};

/**
 * 新增房产单元管理
 * @param data
 */
export const addBuildingUnit = (data: BuildingUnitForm) => {
  return request({
    url: '/system/buildingUnit',
    method: 'post',
    data: data
  });
};

/**
 * 修改房产单元管理
 * @param data
 */
export const updateBuildingUnit = (data: BuildingUnitForm) => {
  return request({
    url: '/system/buildingUnit',
    method: 'put',
    data: data
  });
};

/**
 * 删除房产单元管理
 * @param unitId
 */
export const delBuildingUnit = (unitId: string | number | Array<string | number>) => {
  return request({
    url: '/system/buildingUnit/' + unitId,
    method: 'delete'
  });
};
